/* CSS for Library of Lost Words Game */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #2c1810, #8b4513, #daa520);
    color: #fff;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Responsive height handling for iframe vs standalone */
#gameContainer {
    width: 100%;
    height: 450px; /* Default iframe height */
    position: relative;
    overflow: hidden;
}

/* If opened in new tab, use more screen space */
@media (min-height: 500px) {
    #gameContainer {
        height: 90vh;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.active {
    display: flex !important;
}

/* Cutscene Styles */
.cutscene {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.library-bg {
    background: radial-gradient(circle, rgba(139, 69, 19, 0.9), rgba(44, 24, 16, 0.95));
    border: 3px solid #daa520;
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 0 30px rgba(218, 165, 32, 0.5);
    animation: glow 2s ease-in-out infinite alternate;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
}

.end-bg {
    background: radial-gradient(circle, rgba(25, 25, 112, 0.9), rgba(72, 61, 139, 0.95));
}

@keyframes glow {
    from { box-shadow: 0 0 20px rgba(218, 165, 32, 0.3); }
    to { box-shadow: 0 0 40px rgba(218, 165, 32, 0.7); }
}

.floating-books {
    font-size: 2em;
    animation: float 3s ease-in-out infinite;
    margin-bottom: 15px;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.cutscene-text h2 {
    font-size: 1.8em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.cutscene-text p {
    font-size: 1.1em;
    line-height: 1.4;
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.magic-btn {
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    color: white;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    min-height: 44px; /* Touch-friendly minimum */
}

.magic-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.magic-btn:active {
    transform: translateY(0);
}

/* Game Interface Styles */
#gameInterface {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 10px;
}

.game-header {
    background: rgba(0,0,0,0.3);
    border-radius: 15px;
    padding: 8px 15px;
    backdrop-filter: blur(5px);
}

.stat-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 1em;
    font-weight: bold;
    cursor: help;
}

.stat-icon {
    font-size: 1.2em;
}

/* Challenge Sections */
.challenge-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(255,255,255,0.1);
    border-radius: 15px;
    padding: 15px;
    backdrop-filter: blur(5px);
    border: 2px solid rgba(218, 165, 32, 0.3);
}

.word-display {
    text-align: center;
    margin-bottom: 15px;
}

.glowing-word {
    font-size: 2.5em;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 10px #ffd700;
    animation: pulse 2s infinite;
    margin-bottom: 5px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.word-pronunciation {
    font-size: 1em;
    color: #ddd;
    font-style: italic;
}

.definitions-container {
    flex: 1;
    display: flex;
    align-items: center;
}

.definition-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
}

@media (min-width: 600px) {
    .definition-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.definition-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    padding: 15px;
    border-radius: 12px;
    color: white;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    line-height: 1.3;
    min-height: 44px; /* Touch-friendly */
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.definition-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    background: linear-gradient(135deg, #7c8ff0, #8a5cb8);
}

.definition-btn.correct {
    background: linear-gradient(135deg, #4caf50, #45a049);
    animation: correctAnswer 0.5s ease;
}

.definition-btn.incorrect {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    animation: shake 0.5s ease;
}

@keyframes correctAnswer {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Typing Challenge Styles */
.typing-prompt {
    text-align: center;
    margin-bottom: 15px;
}

.prompt-text {
    font-size: 1.1em;
    margin-bottom: 10px;
    color: #ffd700;
}

.sentence-display {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 10px;
    font-size: 1.2em;
    line-height: 1.4;
    border: 2px solid #daa520;
    margin-bottom: 15px;
}

.typing-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#typingInput {
    flex: 1;
    padding: 15px;
    border: 2px solid #daa520;
    border-radius: 10px;
    font-size: 1.1em;
    background: rgba(255,255,255,0.9);
    color: #333;
    min-height: 50px;
}

#typingInput:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.typing-stats {
    display: flex;
    justify-content: space-between;
    font-size: 1em;
    font-weight: bold;
    color: #ffd700;
}

/* Feedback Styles */
.feedback {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    padding: 15px 25px;
    border-radius: 25px;
    border: 2px solid #daa520;
    z-index: 100;
    max-width: 90%;
    text-align: center;
}

.feedback-content {
    font-size: 1.1em;
    line-height: 1.3;
}

/* Final Stats */
.final-stats {
    margin: 20px 0;
}

.final-stat {
    font-size: 1.2em;
    margin: 8px 0;
    padding: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
}

/* Tooltip Styles */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9em;
    z-index: 1000;
    pointer-events: none;
    max-width: 200px;
    text-align: center;
    border: 1px solid #daa520;
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    .cutscene-text h2 {
        font-size: 1.4em;
    }
    
    .cutscene-text p {
        font-size: 1em;
    }
    
    .glowing-word {
        font-size: 2em;
    }
    
    .definition-btn {
        font-size: 0.9em;
        padding: 12px;
    }
    
    .stat-container {
        gap: 5px;
    }
    
    .stat-item {
        font-size: 0.9em;
    }
}

/* Animation for transitions */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}